package com.aaa.util;

import cn.hutool.crypto.SecureUtil;
import com.aaa.entity.Result;

import java.util.UUID;

/**
 * @author ：Teacher陈
 * @date ：Created in 2020/10/22 15:58
 * @description：我的工具类
 * @modified By：
 * @version: 1.0
 */
public class MyTool {

    /**
     * @create by: Teacher陈
     * @description: 操作成功时需要调用的方法
     * @create time: 2020/10/22 15:59
     * @param obj
     * @return Result
     */
    public static Result getSuccessReturn(Result obj){
        obj.setCode(ReturnStatus.SUCCESS.getCode());
        obj.setMsg(ReturnStatus.SUCCESS.getMessage());
        return obj;
    }
    /**
     * @create by: Teacher陈
     * @description: 操作失败时需要调用的方法
     * @create time: 2020/10/22 15:59
     * @param obj
     * @return Result
     */
    public static Result getFailedReturn(Result obj){
        obj.setCode(ReturnStatus.FAILED.getCode());
        obj.setMsg(ReturnStatus.FAILED.getMessage());
        return obj;
    }

    /**
     * @create by: Teacher陈
     * @description: hutool工具  SecureUtil.md5
     * @create time: 2020/11/2 8:51
     * @param oldStr
     * @return newStr
     */
    public  static String   getMD5Str(String oldStr){
        String newStr = SecureUtil.md5(oldStr);
        return newStr;
    }

    public static void main(String[] args) {
        //明文
        String aa="123456";
        //在123456加密之前，将随机数混入明文，然后进行加密
        String uuid = UUID.randomUUID().toString();
        //将uuid放入数据库保存
        System.out.println(uuid);
        String finalStr=aa+uuid;
        System.out.println(getMD5Str(finalStr));
    }
}
